/**
 * zmn 服务分类-产品分类关联-故障
 * @author yangshuangping
 * @since 2021-11-25 09:21:20
 */
var zmnSelect = null;
layui.define(['index', 'form', 'table', 'laypage', 'layedit', 'laydate', "zmnSelect"], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var laydate = layui.laydate;
    var zmnSelect = layui.zmnSelect;
    form.render(null, "zmn-form");
    labelSelect.init('faultIds', json.listFault.length > 0 ? json.listFault : null, "/serv/categ/ass/selectListfault");
    // 提交
    form.on('submit(zmn-form-submit)', function (obj) {
        var data = obj.field;
        var url = "/serv/categ/ass/saveFauit.action";
        if (zmnUtil.isEmptyNull(data.faultIds)) {
            layer.alert("请选择关联故障现象");
            return false;
        }
        $.ajax({
            async: false,
            type: "POST", url: url,
            dataType: "json", data: {"groupId": data.groupId, "faultIds": data.faultIds},
            success: function (result) {
                if (result.status == 200) {
                    parent.reload(result.message);
                    cancel();
                } else {
                    layui.layer.msg(result.message, {"icon": 2});
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
            }
        })
        return false;
    });
    //对外暴露的接口
    exports('plat_servAssCategory_fault', {});
});

// 取消
function cancel() {
    let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    parent.layer.close(index);
}